package com.gavin.bookstore.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.gavin.bookstore.entity.Book;
import com.gavin.bookstore.mapper.BookMapper;

@RestController
@RequestMapping(value = "book")
public class BookController {
	Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	BookMapper bookMapper;

	@RequestMapping(value = "/bargain", method = RequestMethod.GET)
	public List<Book> getBargainBooks() {
		return bookMapper.selectAllBargain(1, 6);
	}

	@RequestMapping(value = "/latest", method = RequestMethod.GET)
	public List<Book> getLatestBooks() {
		return bookMapper.selectAllOrderByShelveTime(1, 6);
	}

	@RequestMapping(value = "/recommended", method = RequestMethod.GET)
	public List<Book> getRecommendedBooks() {
		return bookMapper.selectAllRecommended(1, 6);
	}
	
	@RequestMapping(value = "/best-selling", method = RequestMethod.GET)
	public List<Book> getBestSellingBooks() {
		return bookMapper.selectBestSelling(1, 6);
	}

}
